import { Component } from '@angular/core';
import { NavController, Platform } from 'ionic-angular';

import { AdMob } from 'ionic-native';
/*
  Generated class for the Menu page.

  See http://ionicframework.com/docs/v2/components/#navigation for more info on
  Ionic pages and navigation.
*/
@Component({
  selector: 'page-menu',
  templateUrl: 'menu.html'
})
export class Menu {
  private admobId: any;
  position : Number;
  constructor(public navCtrl: NavController,private platform: Platform) {
    this.platform = platform;
    if(/(android)/i.test(navigator.userAgent)) {
        this.admobId = {
            banner: 'ca-app-pub-2787085904720807/3591907776',
            interstitial: 'ca-app-pub-2787085904720807/7742905771'
        };
    } else if(/(ipod|iphone|ipad)/i.test(navigator.userAgent)) {
        this.admobId = {
            banner: 'ca-app-pub-2787085904720807/7609978177',
            interstitial: 'ca-app-pub-2787085904720807/9086711370'
        };
    }
  }

  ionViewDidLoad() {
    console.log('Hello Menu Page');
    this.showBanner();
  }

  showBanner() {
    this.platform.ready().then(() => {
       if(AdMob) {
         AdMob.createBanner({
             adId: this.admobId.banner,
            //  adSize: this.size,
             autoShow: true
         }).then(()=>{
            AdMob.showBanner(8);
         });
       }
    });
   }

  hideBanner() {
    this.platform.ready().then(() => {
       if(AdMob) {
           AdMob.hideBanner();
       }
    });
  }

}
